package com.sxj.springsourcecode.springframework.context.support;

import com.sxj.springsourcecode.springframework.context.config.AbstractApplicationContext;
import com.sxj.springsourcecode.springframework.factory.config.BeanDefinition;
import com.sxj.springsourcecode.springframework.factory.support.ConfigurableListableBeanFactory;
import com.sxj.springsourcecode.springframework.factory.support.DefaultListableBeanFactory;

import java.util.HashMap;
import java.util.Map;

/**
 * @ProjectName: spring-source-code
 * @Package: com.sxj.springsourcecode.springframework.context.support
 * @ClassName: AbstractRefreshApplicationContext
 * @Author: sxj
 * @Description:
 * @Date: 2024/2/21 23:40
 * @Version: 1.0.0
 */
public abstract class AbstractRefreshApplicationContext extends AbstractApplicationContext {
    private ConfigurableListableBeanFactory beanFactory = new DefaultListableBeanFactory();

    @Override
    public void refreshBeanFactory() {
        //1 创建bean 工厂
        this.beanFactory = getBeanFactory();

        //2 加载bean定义
        loadBeanDefinitions(beanFactory);
    }

    abstract void loadBeanDefinitions(ConfigurableListableBeanFactory beanFactory);

    @Override
    public ConfigurableListableBeanFactory getBeanFactory() {
        return beanFactory;
    }


    @Override
    public String[] getBeanDefinitionNames() {
        return new String[0];
    }
}
